export default {
    data() {
        return {
            data: {}, //订单数据
            tableData: [], //表格数据
            orser_step: 1, //订单步骤
        }
    },
    //进入页面加载
    mounted: function () {
        var that = this;
        //在缓存中获取值
        that.user_name = sessionStorage.getItem("user_name");
        that.user_id = sessionStorage.getItem("user_id");
        that.token = sessionStorage.getItem("access-token");
        if ((!that.token) || (!that.user_id) || (!that.user_name)) {
            that.$router.push('/login');
        }

        // 获取单个员工数据
        if (that.$route.query.order_id) {
            that.getData(that.$route.query.order_id);
        }

    },

    //方法
    methods: {

        /**
         * 数据
         */
        getData(order_id) {
            var that = this;
            that.tableData = [];
            //请求的数据
            var formData = {};
            formData.token = that.token;
            // 订单ID
            formData.order_id = order_id;
            formData.seller_id = that.user_id;

            //请求邀请者列表
            that.$http.post(that.adminApi.api_url + "/Operatorder/orderdetails", formData, {
                emulateJSON: true
            }).then(
                function (res) {
                    var data = res.body;
                    // 处理成功的结果
                    if (data) {
                        var tableData = [];
                        tableData.push({
                            goods_name: {
                                img: data.picture,
                                title: data.goods_title
                            },
                            type: data.type,
                            price: '￥' + data.adult_price + '.00',
                            supplier: data.seller_name
                        });

                        // 判断订单状态
                        out: if (data.is_pay == 1) {
                            data.oerder_status = '已支付';
                            that.orser_step == 2;

                            if (data.is_refund == 1) {
                                data.oerder_status = '已退款';
                                break out;
                            }

                            if (data.is_travel == 1) {
                                data.oerder_status = '已出行';
                                that.orser_step = 3;

                                if (data.is_over == 1) {
                                    data.oerder_status = '已完成';
                                    that.orser_step = 4;
                                    break out;
                                } else {
                                    data.oerder_status = '未完成';
                                    break out;
                                }
                            } else {
                                data.oerder_status = '未出行';
                                break out;
                            }

                        } else {
                            data.oerder_status = '待支付';
                        }

                        that.data = data;
                        that.tableData = tableData;
                    }
                },
                function () {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ '处理异常' }`
                    });
                });
        },
    }
}